package com.example.administrator.ygddriver.set;

import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.ygddriver.R;
import com.example.administrator.ygddriver.base.BaseActivity;
import com.example.administrator.ygddriver.base.LogInformationBean;
import com.example.administrator.ygddriver.base.UserBean;
import com.example.administrator.ygddriver.into.IntoActivity;
import com.example.administrator.ygddriver.into.login.LogInActivity;
import com.example.administrator.ygddriver.liteorm.SingleLiteOrm;
import com.example.administrator.ygddriver.set.safety.SafetyActivity;
import com.example.administrator.ygddriver.set.xy.XyActivity;
import com.example.administrator.ygddriver.tool.SimpleToolbar;
import com.example.administrator.ygddriver.tool.UrlValuse;
import com.example.administrator.ygddriver.webview.WebActivity;

public class SetActivity extends BaseActivity implements View.OnClickListener {
    private SimpleToolbar simpleToolbar;
    private TextView mNextTv, mBbTv;
    private LinearLayout mXyLl, mSafeLl, mAdoutUsLl;

    @Override
    public int initLayout() {
        return R.layout.activity_set;
    }

    @Override
    public void initView() {
        mNextTv = findViewById(R.id.activity_set_out_tv);
        simpleToolbar = findViewById(R.id.activity_set_stb);
        mSafeLl = findViewById(R.id.activity_set_safety_ll);
        mXyLl = findViewById(R.id.activity_set_yhxy_ll);
        mBbTv = findViewById(R.id.activity_set_yhxy_bb_tv);
        mAdoutUsLl = findViewById(R.id.activity_set_about_us_ll);
        mXyLl.setOnClickListener(this);
        mSafeLl.setOnClickListener(this);
        mNextTv.setOnClickListener(this);
        mAdoutUsLl.setOnClickListener(this);
    }

    @Override
    public void initDate() {
        setSimpleToolbar();
        mBbTv.setText(UrlValuse.VERSION);
    }

    private void setSimpleToolbar() {
        simpleToolbar.setMainTitle("设置");
        simpleToolbar.setMainTitleColor("#000000");
        simpleToolbar.setBackIv(R.mipmap.left_title);
        simpleToolbar.setToolColor("#ffffff");
        simpleToolbar.setBackIvClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_set_out_tv:
                SingleLiteOrm.getSingleLiteOrm(this).SingleLite().deleteAll(UserBean.class);
                SingleLiteOrm.getSingleLiteOrm(this).SingleLite().deleteAll(LogInformationBean.class);
                Intent intent = new Intent(this, IntoActivity.class);
                startActivity(intent);
                break;
            case R.id.activity_set_safety_ll:
                Intent intent2 = new Intent(this, SafetyActivity.class);
                startActivity(intent2);
                break;
            case R.id.activity_set_yhxy_ll:
                Intent intent1 = new Intent(this, XyActivity.class);
                startActivity(intent1);
                break;
            case R.id.activity_set_about_us_ll:
                Intent intent3 = new Intent(this, WebActivity.class);
                intent3.putExtra("URL", UrlValuse.DOMAIN_NAME + UrlValuse.ABOUT_US);
                startActivity(intent3);
                break;
        }
    }
}
